How to group subsequent objects of an array in Javascript

join shbcf.ru